<%@page contentType="text/html" pageEncoding="windows-1252"%>
<%@page import="java.sql.Date"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="startup.utils.Query"%>
<%@page import="startup.model.trip.MissionRequest"%>
<%@page import="startup.model.trip.Vehicle"%>
<%@page import="startup.model.user.Student"%>
<%
	try
	{
		Student student = ( Student )session.getAttribute( "currentSessionUser" );
		student.completeAttributesFromWorkingDB();

		if( request.getParameter( "tripId" ) != null )
		{
			int missionId = Integer.parseInt( request.getParameter( "tripId" ) );
			MissionRequest missionRequest = ( ( Student )session.getAttribute( "currentSessionUser" ) ).getHistory().getMissionById( missionId );
			session.setAttribute( "missionRequest", missionRequest );
		}
		MissionRequest advanceCompensationContainer = ( MissionRequest )session.getAttribute( "missionRequest" );
%>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="windows-1252">
        <title>New Advance Compensation</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
        <!-- Le styles -->
        <link href="styles/bootstrap.css" rel="stylesheet">
        <style type="text/css">
            body {
                padding-top: 60px;
                padding-bottom: 40px;
            }
            .sidebar-nav {
                padding: 9px 0;
            }
        </style>
    </head>
    <body>
        <!--Barra Superiore-->
        <div class="navbar navbar-fixed-top">
			<div class="navbar-inner">
                <div class="container-fluid">
                    <a class="brand" href="#">Student : <%=student.getSurname()%> <%=student.getName()%> </a>
                    <div class="nav pull-right">
                        <ul class="nav">
                            <li>
                                <form action="Logout" method="post">
                                    <button class="btn btn-primary btn-small">Sign out</button>
                                </form>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span3" style="position:fixed;">
					<div class="well sidebar-nav">
						<ul class="nav nav-list">
							<li><a href="javascript:history.back()"><i class="icon-arrow-left"></i> Back</a></li>
							<li class="nav-header">Location</li>
							<li><a href="studentChooseHistoryToShow.jsp"><i class="icon-home"></i> Home</a></li>
							<li><a href="studentActualHistory.jsp"> &nbsp; &bull; <i class="icon-th-large"></i> ACTIVE History</a></li>
							<li><a href="studentTerminatedHistory.jsp"> &nbsp; &bull; <i class="icon-th-large"></i> TERMINATED History</a></li>
							<li><a href="studentDeletedHistory.jsp"> &nbsp; &bull; <i class="icon-th-large"></i> DELETED History</a></li>
							<li class="nav-header">Function</li>
							<li><a href="studentNewMissionRequestSubmission.jsp"><i class="icon-pencil"></i> New Mission Request</a></li>
							<li><a href="studentShowNewAdvanceCompensation.jsp"><i class="icon-pencil"></i> New Advance Compensation</a></li>
							<li class="active"><a href="#"> &nbsp; &bull; <i class="icon-white icon-tasks"></i> Complete the forms </a></li>
							<li><a href="studentShowNewReimbursement.jsp"><i class="icon-pencil"></i> New Reimbursement</a></li>
							<li class="divider"></li>
							<li><a href="studentFAQ.jsp"><i class="icon-info-sign"></i> F.A.Q.</a></li>             
						</ul>
					</div><!--/.well -->
                </div><!--/span-->
                <div class="span9" style="margin-left: 26%;">
                    <form action="studentSubmitAdvanceCompensation.jsp" method="post">
                        <div class="hero-unit">
                            <h1>New Advance Compensation</h1>                        
                        </div>
                        <div class="row-fluid">                            
                            <div class="row-fluid">
                                <div class="span5">
                                    <h2>
                                        Data you have before the mission:
                                    </h2>
                                    <br />
                                    <br />
                                    <h4>
                                        Registration fee for the mission *
                                    </h4>
                                    <br />
                                    <input name="registrationFee" type="number" value="0.0" />
                                    <br />
                                    <br />
                                    <h4>
                                        Tickets 
                                    </h4>
                                    <br />
                                    <div class="thumbnail">
                                        <h4>
                                            Departure:
                                        </h4>
                                        <h4> From: *</h4>
                                        <input name="fromDeparture" type="text" value="">
                                        <h4> To: *</h4>
                                        <input name="toDeparture" type="text" value="">
                                        <h4> Date: *</h4>
                                        <input name="dateDeparture" type="date" value="<%=advanceCompensationContainer.getPlannedStartDate() %>">
                                    </div>
                                    <br />
                                    <br />
                                    <div class="thumbnail">
                                        <h4>
                                            Return:
                                        </h4>
                                        <h4> From: *</h4>
                                        <input name="fromReturn" type="text" value="">
                                        <h4> To: *</h4>
                                        <input name="toReturn" type="text" value="">
                                        <h4> Date: *</h4>
                                        <input name="dateReturn" type="date" value="<%=advanceCompensationContainer.getPlannedEndDate()%>">
                                    </div>                                    
                                </div>
                                <div class="span5">
                                    <h2>
                                        Costs that you foresee: 
                                    </h2>
                                    <br />
                                    <br />
                                    <h4>
                                        Foreseen transportation costs *
                                    </h4>
                                    <br />
                                    <input name="foreseenTransportation" type="number" value="0.0" />
                                    <br />
                                    <br />
                                    <h4>
                                        Foreseen lodging costs *
                                    </h4>
                                    <br />
                                    <input name="foreseenLodging" type="number" value="0.0" />
                                    <br />
                                    <br />
                                    <h4>
                                        Foreseen meals costs *
                                    </h4>
                                    <br />
                                    <input name="foreseenMeals" type="number" value="0.0" />
                                    <hr />
                                    <h2>
                                        The amount you want to withdraw:
                                    </h2>
                                    <br />
                                    <br />
                                    <%
										if( advanceCompensationContainer.getArePersonalFundsUsed() )
										{
                                    %>
                                    <h4>
                                        Personal funds amount: <%= student.getPersonalFunds() %> <br />
                                        How many personal funds do you want to use? *
                                    </h4>
                                    <br/>
                                    <input name="personalFundAmount" type="number" value="0" />
                                    <br />
                                    <br />
                                    <%                                            }
										if( advanceCompensationContainer.getFirstAlternativeFundName() != null &&
											!advanceCompensationContainer.getFirstAlternativeFundName().equals( "" ) )
										{
                                    %>
                                    <div class="thumbnail">
                                        <h4>
                                            Fund name:
                                            <br />
                                            <%= advanceCompensationContainer.getFirstAlternativeFundName()%>
                                        </h4>
                                        <br />
                                        <br />
                                        <h4>
                                            First external fund amount: *
                                        </h4>
                                        <br/>
                                        <input name="firstFundAmount" type="number" value="0" />
                                    </div>
                                    <br />
                                    <br />
                                    <%}
										if( advanceCompensationContainer.getSecondAlternativeFundName() != null &&
											!advanceCompensationContainer.getSecondAlternativeFundName().equals( "" ) )
										{
                                    %>
                                    <div class="thumbnail">
                                        <h4>
                                            Fund name:
                                            <br />
                                            <%= advanceCompensationContainer.getSecondAlternativeFundName()%>
                                        </h4>
                                        <br />
                                        <br />
                                        <h4>
                                            Second external fund amount: *
                                        </h4>
                                        <br/>
                                        <input name="secondFundAmount" type="number" value="0" />
                                    </div>
                                    <br />
                                    <br />
                                    <%}%>                                        
                                </div>
                            </div>
                            <hr />
                            <div class="row-fluid"> 
                                <div class="span5">                                    
                                    <h2>
                                        How you wish to be paid:
                                    </h2>
                                    <br />
                                    <br />
                                    <h4>
                                        Method of payment: *
                                    </h4>
                                    <br />
                                    <input name="paymentMethod" type="radio" value="CASH" /> Cash
                                    <br />
                                    <input name="paymentMethod" type="radio" value="BANK" /> Bank Account 
									<p>
										Please note that if you spend more money than your available funds or funds that you indicated, you will not be reimbursed the difference.
									</p>
                                </div>
                            </div>
                        </div>
                        <hr />
                        <div class="row-fluid">
                            <table>
                                <tr>                                                    
                                    <td>
                                        <a class="btn btn-primary" data-toggle="modal" href="#Submit" >Submit</a>    
                                        <!--MODAL che appare quando si clicca su Refuse-->
                                        <div class="modal hide fade" id="Submit">
                                            <div class="modal-header">
                                                <button class="close" data-dismiss="modal">x</button>
                                                <h3>Are You Sure?</h3>
                                            </div>
                                            <div class="modal-body">
                                                <p>Click "Save Changes" to SUBMIT the trip, Close instead.</p>
                                            </div>
                                            <div class="modal-footer">    
                                                <table>
                                                    <tr>                                                    
                                                        <td>
                                                            <button class="btn btn-primary btn-success">Save Changes</button>
                                                        </td>
                                                        <td>
                                                            <button class="btn" data-dismiss="modal">Close</button>
                                                        </td>
                                                    </tr>
                                                </table>  
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <button class="btn btn-primary" type="reset"  >Reset</button>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </form>
                </div>
            </div>
        </div><!--/.fluid-container-->
        <div class="navbarCC navbar-fixed-bottom">
            <div class="navbarCC-inner">
                <div class="container-fluid">				
                    <a class="brand" href="#">&copy; 2012 Startup</a>					
                </div>
            </div>
        </div>
		<!-- Il javascript -->
		<script src="js/jquery.js"></script>
		<script src="js/bootstrap.js"></script>
	</body>
</html>
<%
	}
	catch( RuntimeException runtimeException )
	{
		if( runtimeException.getClass().equals( NullPointerException.class ) )
		{
			runtimeException = new NullPointerException( "The session has timed out:<br />" + "" +
														 "try reloading page.<br />" +
														 "If the problem persists, please report it to the administration." );
		}
		request.setAttribute( "exception", runtimeException );
		request.getRequestDispatcher( "errorPage.jsp" ).forward( request, response );
	}
%>